/**
 *
 */
package com.mydemo.temp;

import org.apache.commons.lang.StringUtils;

/**
 * 交易的status
 * @author guwei
 *
 */
public enum EnumJobStatus {
    CREATE("100", "交易创建"),

    PAY_SUCESS("201", "付款成功"),

    TRANSACTION_SUCESS("301", "交易成功"),

    TRANSACTION_END("401", "交易结束"),

    TRANSACTION_FAIL("998", "交易失败"),

    TRANSACTION_CLOSE("999", "交易关闭"),

    REFUNDCREATIONSUCCESS("900", "退款创建成功"),

    REPLACEREFUNDCREATIONSUCCESS("910", "代发退款创建成功"),

    TRANSFERREFUNDCREATIONSUCCESS("911", "转账退款创建成功"),

    SUCCESSFULSETTLEMENT("901", "退结算成功"),

    SUCCESSFULREFUND("951", "退款成功"),

    REFUNDFAILED("952", "退款失败"),

    WAITING("P", "等待中"),

    SUCCESS("S", "成功"),

    SUCCESSLONG("success", "成功"),

    FAIL("F", "失败"),

    REPEATEDPAYMENT("RP", "重复支付"),

    REPEATPAYMENTREFUND("RR", "重复支付退款"),

    REFUND("R", "退款"),

    DRAFT("draft", "草创"),

    COMPLEMENT("complement", "信息补全中"),

    PENDING("pending", "待处理"),

    SENDING("sending", "提交PFS中"),

    ACCEPTED("accepted", "申请成功"),

    FAILED("failed", "处理失败"),

    SUBMITTED("submitted", "提交银行成功"),

    BANKFAILED("bankFailed", "提交银行失败"),

    BANKSUCCESS("bankSuccess", "银行处理成功"),

    REFUNDED("refunded", "银行退票"),

    REFUNDTICKET("refundTicket", "银行退票"),
    ;;

    private String code;
    private String message;

    private EnumJobStatus(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static EnumJobStatus getByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (EnumJobStatus item : values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }

    public static String getMsgByCode(String code) {
        EnumJobStatus em = getByCode(code);
        if (em != null) {
            return em.getMessage();
        }
        return code;
    }

    public static void main(String[] args) {
        for (EnumJobStatus code : EnumJobStatus.values()) {
            System.out.println(code.getCode().toLowerCase() + "|"
                    + code.getMessage());
        }
    }

}
